package com.qf.application.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.application.commons.utils.R;
import com.qf.application.entity.Dept;
import com.qf.application.entity.Role;
import com.qf.application.service.IDeptService;
import com.qf.application.service.IEmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/dept")
public class DeptController {

    @Autowired
    private IDeptService deptService;

    @GetMapping("/list")
    public R list() {
        return R.ok().put("data", deptService.list());
    }
    @PostMapping("/page")
    public R page(@RequestBody Page<Dept> page) {
        return R.ok(deptService.page(page));
    }

    @PostMapping("/save")
    public R save(@RequestBody Dept dept) {
        return R.write(deptService.save(dept));
    }

    @PostMapping("/update")
    public R update(@RequestBody Dept dept) {
        return R.write(deptService.updateById(dept));
    }

    @GetMapping("/info/{id}")
    public R info(@PathVariable Integer id) {
        return R.ok(deptService.getById(id));
    }

    @PostMapping("/remove")
    public R remove(@RequestBody List<Integer> ridList) {
        return R.write(deptService.removeBatchByIds(ridList));
    }
}
